﻿//-----------------------------------------------------------------------
// <copyright file="BoldLabel.cs" company="Redmist">
//     Copyright (c) Damien T Smith. All rights reserved.
// </copyright>
// <author>Damien Smith</author>
//-----------------------------------------------------------------------

namespace Redmist.UsageMonitor.CustomControls
{
    using System.Drawing;
    using System.Windows.Forms;

    /// <summary>A custom label based on a System.Windows.Forms.Label that inherits the parent container's font but applies a bold style.</summary>
    /// <remarks>Avoids the need to set the font for all bold labels.</remarks>
    public class BoldLabel : Label
    {
        /// <summary>Gets or sets a value indicating whether the label text should use a bold font.</summary>
        public bool BoldText { get; set; }

        /// <summary>Sets the font to bold when painting the control.</summary>
        /// <param name="e">A System.Windows.Forms.PaintEventArgs representing the paint event arguments.</param>
        /// <remarks>Skips the bold setting in design mode so that the font setting is not stored in the designer.</remarks>
        protected override void OnPaint(PaintEventArgs e)
        {
            if (!this.DesignMode && this.BoldText)
            {
                this.Font = new Font(this.Font, FontStyle.Bold);
            }

            base.OnPaint(e);
        }
    }
}
